﻿using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration.File;
using Ocelot.DependencyInjection;
using Spark.Ocelot.Remote.ServiceDiscovery;

namespace Spark.Ocelot.Remote
{
    public static class OcelotBuilderExtensions
    {
        public static IOcelotBuilder AddRemoteServiceDiscovery(this IOcelotBuilder builder)
        {
            builder.Services.AddSingleton(RemoteServiceDiscoveryFinderDelegate.Get);
            return builder;
        }

        public static IOcelotBuilder AddConfigStoredInRemote(this IOcelotBuilder builder, string section = "")
        {
            builder.Services.Configure<FileConfiguration>(builder.Configuration.GetSection(section));
            return builder;
        }
    }
}